Skip to content

[INFRA-746] Run two nginx worker processes - #33

Merged
itskingori merged 1 commit into
masterfrom
infra-746-nginx-proxy-workers
Dec 1, 2026
Merged

itskingori merged 1 commit into
masterfrom
infra-746-nginx-proxy-workers

Conversation

@itskingori

Copy link
Copy Markdown
Member

Pins nginx to two worker processes instead of auto, so the proxy no longer starts one worker per node CPU when it runs as a sidecar with a small CPU limit.

Motivation

worker_processes auto counts the CPUs nginx can see and does not read the container's CPU limit. On an 8-core node the proxy starts eight workers, each with its own aio threads pool, alongside the OTel exporter. Under a 100m limit they all share 10ms of CPU per 100ms period, so start-up and short bursts spend the quota in a few milliseconds and requests wait for the next period. Two workers at worker_connections 8000 each are far more than a per-pod proxy needs.

Changes

  • config/main.conf sets worker_processes 2;.
  • Adds the 1.31.9-1 changelog entry.

Risk

  • Low. Connection capacity drops from 8 × 8000 to 2 × 8000 per pod on 8-core nodes, still well above what one pod's proxy handles.
  • A deployment that needs more workers can still mount its own /etc/nginx/main.conf, as the README describes.
  • Apps pick the image up only once Shipyard's sidecar tag moves to 1.31.9-1, so rollback is keeping or restoring 1.31.9 there.

Testing

  • Docker isn't available on my machine, so I haven't built the image locally. CI's build is the check here.
  • After release, nginx -T in the image should show worker_processes 2;, and ps should list two nginx: worker process entries.

Rollout

  1. Merge, then tag 1.31.9-1 to publish the image.
  2. Bump the nginx-proxy tag in Shipyard's sidecar builder to 1.31.9-1.

References

worker_processes auto starts one worker per CPU it can see, and it
does not read the container's CPU limit. As a sidecar on an 8-core
node with a 100m limit, eight workers and their aio threads share a
10ms-per-100ms quota and are throttled together on start-up and
bursts. Two workers with 8000 connections each are plenty for a
per-pod proxy.

A deployment that needs more can still mount its own main.conf.
@itskingori
itskingori marked this pull request as ready for review December 1, 2026 10:16
@itskingori
itskingori requested a review from a team as a code owner December 1, 2026 10:16
@itskingori
itskingori enabled auto-merge December 1, 2026 10:23

@zacblazic zacblazic left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. worker_processes auto only counts the node's CPUs, so pinning it to 2 makes sense for the sidecar. I checked our sidecar deployments and they all run with a small CPU limit and don't override main.conf, so they'll pick this up cleanly.

A couple of small things (non-blocking):

  • Capacity note: a proxied request uses two file descriptors, and worker_rlimit_nofile is 8192. So each worker tops out around 4k connections, not 8k. Still plenty.
  • README: the core config example still shows worker_processes auto;.

Same issue elsewhere (FYI): a few of our apps run their own nginx with worker_processes auto; and a small CPU limit, so they'll hit the same throttling. This PR doesn't reach them, but it's a one-line fix in each of their configs. Happy to share the list.

Idea for later: the upstream nginx image has a script that sets the worker count from the container's CPU limit. It can't edit our main.conf as it stands. A small entrypoint script could write the value to /tmp, and main.conf could include it. Then each deployment would size itself automatically.

@itskingori
itskingori merged commit e11bd3f into master Dec 1, 2026
2 checks passed
@itskingori
itskingori deleted the infra-746-nginx-proxy-workers branch December 1, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants